package com.spider.moudle.handler;

import com.spider.moudle.task.TaskWorker;
import com.spider.moudle.util.CenterExecutorUtil;
import com.spider.moudle.util.PropertiesUtil;


/**
 * Created by Linbo Hu on 2017/11/28.
 * 任务处理器(从kafka拉取任务)
 */
public class TaskHandler {


    public static void handle() {
        String workMode = PropertiesUtil.getVal("spider.work.mode");
        String speechTopic = PropertiesUtil.getVal("kafka.speech.task.topic");
        String userTopic = PropertiesUtil.getVal("kafka.user.task.topic");
        switch (workMode) {
            case "SPEECH": {
                CenterExecutorUtil.execute(new TaskWorker(speechTopic));
                break;
            }
            case "USER": {
                CenterExecutorUtil.execute(new TaskWorker(userTopic));
                break;
            }
            case "BOTH": {
                CenterExecutorUtil.execute(new TaskWorker(speechTopic));
                CenterExecutorUtil.execute(new TaskWorker(userTopic));
                break;
            }
            default: {
                System.out.println("the value of spider.work.mode is unavailable");
            }
        }



    }


    public static void main(String[] args) {
        TaskHandler.handle();
    }

}
